package com.ai.analysis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ai.error.KwListenerExcption;
import com.base.SnThread;
import com.biz.dev.Device;

/**
 * @Description 关键字监听
 * @ClassName KwListener
 * @Date 2017年1月23日 下午2:04:31
 * @Author yanghao Copyright (c) All Rights Reserved, 2017.
 */
public class KwListener extends SnThread {

	private static Map<String, Device> map = new HashMap<String, Device>();

	public void distTask(String msg) {
		
	}

	public void addHandler(String key, Device hd) throws KwListenerExcption {
		if (map.get(key) != null) {
			map.put(key, hd);
		} else {
			throw new KwListenerExcption("关键字" + key + "已被注册");
		}
	}

	public void registKeyHandler(Device dev) throws KwListenerExcption {
		List<String> list = dev.getKeys();
		for (String key : list) {
			addHandler(key, dev);
		}
	}

}
